{extend name="index_layout"/}
{block name="main"}
<form class="layui-form" method="post">

    <div class="layui-form-item">
        <label class="layui-form-label">名称</label>
        <div class="layui-input-block">
            <input type="text" name="name" lay-verify="required" autocomplete="off" placeholder="名称"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">优惠券类型</label>
        <div class="layui-input-block">
            <select name="cate_id" lay-verify="required">
                <option value="">请选择经优惠券类型</option>
                {if !empty($coupon_cate_list)}
                {foreach $coupon_cate_list as $key}
                <option
                <?php if( $key['id'] == $data['cate_id']){ ?>
                selected
                <?php }?>
                value="{$key.id}"  name="cate_id">
                {$key.name}
                </option>
                {/foreach}
                {/if}
            </select>
        </div>
    </div>

<!--    <div class="layui-form-item" id="jifen">-->
<!--        <label class="layui-form-label">所需积分(积分类型填写)</label>-->
<!--        <div class="layui-input-block">-->
<!--            <input type="number" name="fraction" value="10"  autocomplete="off" placeholder="所需积分"-->
<!--                   class="layui-input">-->
<!--        </div>-->
<!--    </div>-->


    <div class="layui-form-item">
        <label class="layui-form-label">面值</label>
        <div class="layui-input-block">
            <input type="number" name="value" lay-verify="required"  autocomplete="off" placeholder="面值"
                   class="layui-input" step="0.01">
        </div>
    </div>

    <div class="layui-form-item" >
        <label class="layui-form-label">是否设置最低消费</label>
        <div class="layui-input-block" id="is_c">

            <input type="radio" name="is_limit" checked value="0" title="不设置" lay-filter="ccc">

            <input type="radio" name="is_limit" value="1" title="设置" lay-filter="ccc">
        </div>
    </div>


    <div class="layui-form-item is_limit" style="display: none;">
        <label class="layui-form-label">最低消费(最低消费填写)</label>
        <div class="layui-input-block">
            <input type="number" name="min_amount" value="0.00" lay-verify="required"  autocomplete="off" placeholder="最低消费"
                   class="layui-input" step="0.01">
        </div>
    </div>

<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label ">领取时间</label>-->
<!--        <div class="layui-input-block">-->
<!--            {:Form::datetime("start_time",'',['class'=>'layui-input','data-date-range'=>'&#45;&#45;',"lay-verify"=>"required"])}-->
<!--        </div>-->
<!--    </div>-->

    <div class="layui-form-item">
        <label class="layui-form-label">有效类型</label>
        <div class="layui-input-block" id="is_c2">

            <input type="radio" name="effect_type" value="1" title="时间范围" lay-filter="ccc2">

            <input type="radio" name="effect_type" checked value="2" title="相对时间" lay-filter="ccc2">
        </div>
    </div>

    <div class="layui-form-item effect_start" style="display: none;">
        <label class="layui-form-label ">有效范围(时间范围填写)</label>
        <div class="layui-input-block">
            {:Form::datetime("effect_start",'',['class'=>'layui-input','data-date-range'=>'--'])}
        </div>
    </div>

    <div class="layui-form-item effect_day">
        <label class="layui-form-label">有效天数(相对时间填写)</label>
        <div class="layui-input-block">
            <input type="number" name="effect_day"   autocomplete="off" placeholder="有效天数"
                   class="layui-input">
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">库存类型</label>
        <div class="layui-input-block" id="is_c3">

            <input type="radio" name="stock_type" checked value="1" title="不限量" lay-filter="ccc3">

            <input type="radio" name="stock_type" value="2" title="限量" lay-filter="ccc3">
        </div>
    </div>

    <div class="layui-form-item total_count2" style="display: none;">
        <label class="layui-form-label">设置数量(限量填写)</label>
        <div class="layui-input-block">
            <input type="number" name="total_count"  autocomplete="off" placeholder="设置数量"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">优惠券说明</label>
        <div class="layui-input-block">
            <input type="text" name="desc"  autocomplete="off" placeholder="优惠券说明"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-block">
            <input type="number" name="sort" value="{$data.sort}"  autocomplete="off" placeholder="排序"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item layer-footer">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
{/block}
{block name="script"}
<script type="text/javascript">
    layui.use(['yznForm','form'], function () {
        var yznForm = layui.yznForm;
        var form = layui.form;
        var $ = layui.jquery;
        yznForm.bindevent($("form.layui-form"));

        form.on('radio(ccc)',function (data){

            if($('#is_c input[name="is_limit"]:checked ').val() ==0){
                $(".is_limit").hide();
            }else{
                $(".is_limit").show();
            }

            form.render();
        });

        form.on('radio(ccc2)',function (data){
            if($('#is_c2 input[name="effect_type"]:checked ').val() ==1){
                $(".effect_start").show();
                $(".effect_day").hide();
            }else{
                $(".effect_start").hide();
                $(".effect_day").show();
            }
            form.render();
        });

        form.on('radio(ccc3)',function (data){

            if($('#is_c3 input[name="stock_type"]:checked ').val() ==1){
                $(".total_count2").hide();
            }else{
                $(".total_count2").show();
            }
            form.render();
        });

    });

</script>
{/block}